package br.com.async.core.domain.enterprise;

import java.util.Calendar;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import br.com.async.core.domain.AbstractBookmarks;

@Entity(name = "tb_profiledetail")
public class ProfileDetail implements AbstractBookmarks {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	@Id
	@SequenceGenerator(allocationSize = 1, initialValue = 1, name = "profiledetail_seq", sequenceName = "profiledetail_seq")
	@GeneratedValue(generator = "profiledetail_seq", strategy = GenerationType.AUTO)
	@JoinColumn(nullable = false)
	private Integer code;
	private String aditionalResume;
	@Temporal(TemporalType.TIMESTAMP)
	private Calendar businessHourInitial;
	@Temporal(TemporalType.TIMESTAMP)
	private Calendar businessHourFinal;
	@Enumerated(EnumType.STRING)
	private Profile profile;
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
	private Set<OperatingDay> operatingDay;

	public ProfileDetail() {
	}

	public ProfileDetail(String aditionalResume, Calendar businessHourInitial,
			Calendar businessHourFinal, Profile profile,
			Set<OperatingDay> operatingDay) {
		super();
		this.aditionalResume = aditionalResume;
		this.businessHourInitial = businessHourInitial;
		this.businessHourFinal = businessHourFinal;
		this.profile = profile;
		this.operatingDay = operatingDay;
	}

	public Integer getCode() {
		return code;
	}

	public void setCode(Integer code) {
		this.code = code;
	}

	public String getAditionalResume() {
		return aditionalResume;
	}

	public void setAditionalResume(String aditionalResume) {
		this.aditionalResume = aditionalResume;
	}

	public Calendar getBusinessHourInitial() {
		return businessHourInitial;
	}

	public void setBusinessHourInitial(Calendar businessHourInitial) {
		this.businessHourInitial = businessHourInitial;
	}

	public Calendar getBusinessHourFinal() {
		return businessHourFinal;
	}

	public void setBusinessHourFinal(Calendar businessHourFinal) {
		this.businessHourFinal = businessHourFinal;
	}

	public Profile getProfile() {
		return profile;
	}

	public void setProfile(Profile profile) {
		this.profile = profile;
	}

	public Set<OperatingDay> getOperatingDay() {
		return operatingDay;
	}

	public void setOperatingDay(Set<OperatingDay> operatingDay) {
		this.operatingDay = operatingDay;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((aditionalResume == null) ? 0 : aditionalResume.hashCode());
		result = prime
				* result
				+ ((businessHourFinal == null) ? 0 : businessHourFinal
						.hashCode());
		result = prime
				* result
				+ ((businessHourInitial == null) ? 0 : businessHourInitial
						.hashCode());
		result = prime * result + ((code == null) ? 0 : code.hashCode());
		result = prime * result
				+ ((operatingDay == null) ? 0 : operatingDay.hashCode());
		result = prime * result + ((profile == null) ? 0 : profile.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		ProfileDetail other = (ProfileDetail) obj;
		if (aditionalResume == null) {
			if (other.aditionalResume != null)
				return false;
		} else if (!aditionalResume.equals(other.aditionalResume))
			return false;
		if (businessHourFinal == null) {
			if (other.businessHourFinal != null)
				return false;
		} else if (!businessHourFinal.equals(other.businessHourFinal))
			return false;
		if (businessHourInitial == null) {
			if (other.businessHourInitial != null)
				return false;
		} else if (!businessHourInitial.equals(other.businessHourInitial))
			return false;
		if (code == null) {
			if (other.code != null)
				return false;
		} else if (!code.equals(other.code))
			return false;
		if (operatingDay == null) {
			if (other.operatingDay != null)
				return false;
		} else if (!operatingDay.equals(other.operatingDay))
			return false;
		if (profile != other.profile)
			return false;
		return true;
	}

}
